from google.appengine.ext import db

class CustomTheme(db.Model):
	html = db.TextProperty()
	
class URLs(db.Model):
	url = db.StringProperty()
	nbOfTimesUsed = db.IntegerProperty()
	dateAdded = db.DateTimeProperty(auto_now_add=True)
	counter = db.IntegerProperty()
	customTheme = db.ReferenceProperty(CustomTheme)
	up = db.BooleanProperty()

class URLCounter(db.Model):
	current = db.IntegerProperty()

# Executed only the first time ever! When no URL has been entered yet (important locally when datastore is emptied)
firstCounterQuery = URLCounter.all().fetch(1)
if len(firstCounterQuery) == 0:
	firstCounter = URLCounter(current=1)
	firstCounter.put()